import subprocess, shlex, os
import credentials
os.chdir('/home/dms/roque')
#verbose = True
verbose = False
verbose_string = (' --verbose' if verbose else '')
command_line = 'python /home/dms/powermeter/post_readings_devices.py '+credentials.powermeter_token()+' '+credentials.powermeter_variable()+' --unit=W --interval --period=0'+verbose_string
# args = shlex.split(command_line)
# p1 = subprocess.Popen(["python", "send_to_powermeter.py"], stdout=subprocess.PIPE)
# p2 = subprocess.Popen(args, stdin=p1.stdout, stdout=subprocess.PIPE)
# output = p2.communicate()[0]
command_line = 'python send_to_powermeter.py | ' + command_line
print command_line
output = os.system(command_line)
print output

